Skip to content

Add aria-labels to PDF link annotations for accessibility#2049

Open
zhufangu wants to merge 2 commits intowojtekmaj:mainfrom
zhufangu:add-aria-labels-to-pdf-links
Open

Add aria-labels to PDF link annotations for accessibility#2049
zhufangu wants to merge 2 commits intowojtekmaj:mainfrom
zhufangu:add-aria-labels-to-pdf-links

Conversation

@zhufangu
Copy link
Copy Markdown

@zhufangu zhufangu commented Dec 30, 2025

PDF link annotations lack discernible names, causing Lighthouse accessibility warnings and poor screen reader support. (#1424)

This update adds aria-label attributes to links using overlaidText from annotation data:

  1. Add setAnnotationContext/clearAnnotationContext to LinkService to store annotation data
  2. Set annotation context before rendering annotation layer
  3. Use overlaidText from annotations in addLinkAttributes to set aria-label

Reproduce:

  1. Load test.pdf in the test page
  2. Open DevTools → Elements tab
  3. Select an <a> element in the annotation layer
  4. View ARIA attributes in the Accessibility tab

Effect:

  • Before: Links have no aria-label, causing Lighthouse warnings
    ScreenShot_2025-12-30_030309_368
  • After: Links have aria-label with meaningful text for screen readers
    ScreenShot_2025-12-30_030045_323

@zhufangu zhufangu marked this pull request as ready for review December 30, 2025 09:28
@wojtekmaj
Copy link
Copy Markdown
Owner

This is REALLY sweet improvement, thank you for this!!!

@anton-mauritzson
Copy link
Copy Markdown

Is this gonna get merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants